package com.example.demo.mingling;

import redis.clients.jedis.Protocol;

public class RemoteController {

    /**
     * 开按钮命令
     *
     */
    Comand[] onCommands;
    Comand[] offCommands;


    /**
     *
     * 执行测小命令
     */
    Comand undoComand;

    /**
     * 构造器完成对按钮初始化
     */
    public RemoteController(){
        onCommands=new Comand[5];
        offCommands=new Comand[5];
        for (int i = 0; i < 5; i++) {
            onCommands[i]=new NoComand();
            offCommands[i]=new NoComand();

        }
    }

    /**
     *
     * 给我们的按钮设置需要的命令
     */
    public void setComand(int no,Comand onComand,Comand offComand){
        onCommands[no]=onComand;
        offCommands[no]=offComand;
    }

    /**
     *
     * 按下开按钮
     */
    public void onButtonWasPushed(int no){
        onCommands[no].excute();
        undoComand=onCommands[no];
    }

    /**
     *
     * 按下关按钮
     */
    public void offButtonWasPushed(int no){
        offCommands[no].excute();
        undoComand=offCommands[no];
    }
    /**
     *
     * 按下撤销按钮
     */
    public void undoButtonWasPushed(){
        undoComand.undo();
    }


}
